/**
 * 
 */
package com.sidom.movieIndexer.factory;

import com.sidom.movieIndexer.domain.Movie;
import com.sidom.movieIndexer.domain.file.MovieFile;
import com.sidom.movieIndexer.domain.google.GoogleSearchResult;
import com.sidom.movieIndexer.domain.imdb.ImdbResult;
import com.sidom.movieIndexer.factory.ImdbResultFactory.TestImdbResult;

import static com.sidom.movieIndexer.factory.MovieFileFactory.TesMovieFile;
import static com.sidom.movieIndexer.factory.GoogleSearchResultFactory.TestGoogleSearchResult;;

/**
 * Factory class for creating {@link Movie} objects.
 * 
 * @author Siebe
 */
public class MovieFactory {
	public enum TestMovie {
		BOURNE_IDENTITY_CD1, 
		BOURNE_IDENTITY_CD2, 
		BOURNE_IDENTITY_TXT, 
		GONE_IN_60_SECONDS, 
		THE_MATRIX, 
		NO_MOVIE_WITH_THIS_NAME, 
		THE_ISLAND, 
		THE_ITALIAN_JOB, 
		TRANSPORTER, 
		EQUILIBRIUM_CD1, 
		EQUILIBRIUM_CD2, 
		SWORDFISH_CD1, 
		SWORDFISH_CD2, 
		YOUTUBE,
		BOX_OFFICE,
		THE_MTRX;
	}
	
	/**
	 * Create a {@link Movie}.
	 * @return The {@link Movie}.
	 */
	public static Movie createMovie(){
		return new Movie();
	}
	
	/**
	 * Create a {@link Movie}.
	 * @param movieFile The {@link MovieFile}.
	 * @return The {@link Movie} with the {@link MovieFile}.
	 */
	public static Movie createMovie(MovieFile movieFile){
		Movie movie = createMovie();
		movie.setMovieFile(movieFile);
		return movie;
	}
	
	/**
	 * Create a {@link Movie}.
	 * @param movieFile The {@link MovieFile}.
	 * @param googleSearchResult The {@link GoogleSearchResult}.
	 * @return The {@link Movie} with the {@link MovieFile} and {@link GoogleSearchResult}.
	 */
	public static Movie createMovie(MovieFile movieFile, GoogleSearchResult googleSearchResult){
		Movie movie = createMovie(movieFile);
		movie.setGoogleSearchResult(googleSearchResult);
		return movie;
	}
	
	/**
	 * Create a {@link Movie}.
	 * @param movieFile The {@link MovieFile}.
	 * @param googleSearchResult The {@link GoogleSearchResult}.
	 * @param imdbResult The {@link ImdbResult}.
	 * @return The {@link Movie} with the {@link MovieFile} and {@link GoogleSearchResult}.
	 */
	public static Movie createMovie(MovieFile movieFile, GoogleSearchResult googleSearchResult, ImdbResult imdbResult){
		Movie movie = createMovie(movieFile);
		movie.setGoogleSearchResult(googleSearchResult);
		movie.setImdbResult(imdbResult);
		return movie;
	}
	
	/**
	 * Create a {@link Movie}.
	 * @param testMovie The {@link TestMovie}.
	 * @return The {@link Movie} with the {@link MovieFile} and {@link GoogleSearchResult}.
	 */
	public static Movie createMovie(TestMovie testMovie){
		switch (testMovie) {
			case BOURNE_IDENTITY_CD1:
				return createMovie(MovieFileFactory.createMovieFile(TesMovieFile.BOURNE_IDENTITY_CD1), 
								   GoogleSearchResultFactory.createGoogleSearchResult(TestGoogleSearchResult.BOURNE_IDENTITY),
								   ImdbResultFactory.createImdbResult(TestImdbResult.BOURNE_IDENTITY));
			case BOURNE_IDENTITY_CD2:
				return createMovie(MovieFileFactory.createMovieFile(TesMovieFile.BOURNE_IDENTITY_CD2), 
								   GoogleSearchResultFactory.createGoogleSearchResult(TestGoogleSearchResult.BOURNE_IDENTITY));
			case BOURNE_IDENTITY_TXT:
				return createMovie(MovieFileFactory.createMovieFile(TesMovieFile.BOURNE_IDENTITY_TXT), 
								   GoogleSearchResultFactory.createGoogleSearchResult(TestGoogleSearchResult.BOURNE_IDENTITY));
			case GONE_IN_60_SECONDS:
				return createMovie(MovieFileFactory.createMovieFile(TesMovieFile.GONE_IN_60_SECONDS), 
								   GoogleSearchResultFactory.createGoogleSearchResult(TestGoogleSearchResult.GONE_IN_60_SECONDS),
								   ImdbResultFactory.createImdbResult(TestImdbResult.GONE_IN_60_SECONDS));
			case THE_MATRIX:
				return createMovie(MovieFileFactory.createMovieFile(TesMovieFile.THE_MATRIX), 
								   GoogleSearchResultFactory.createGoogleSearchResult(TestGoogleSearchResult.THE_MATRIX),
								   ImdbResultFactory.createImdbResult(TestImdbResult.THE_MATRIX));
			case NO_MOVIE_WITH_THIS_NAME:
				return createMovie(MovieFileFactory.createMovieFile(TesMovieFile.NO_MOVIE_WITH_THIS_NAME), 
								   GoogleSearchResultFactory.createGoogleSearchResult(TestGoogleSearchResult.NO_MOVIE_WITH_THIS_NAME));
			case THE_ISLAND:
				return createMovie(MovieFileFactory.createMovieFile(TesMovieFile.THE_ISLAND), 
								   GoogleSearchResultFactory.createGoogleSearchResult(TestGoogleSearchResult.THE_ISLAND),
								   ImdbResultFactory.createImdbResult(TestImdbResult.THE_ISLAND));
			case THE_ITALIAN_JOB:
				return createMovie(MovieFileFactory.createMovieFile(TesMovieFile.THE_ITALIAN_JOB), 
								   GoogleSearchResultFactory.createGoogleSearchResult(TestGoogleSearchResult.THE_ITALIAN_JOB));
			case TRANSPORTER:
				return createMovie(MovieFileFactory.createMovieFile(TesMovieFile.TRANSPORTER), 
								   GoogleSearchResultFactory.createGoogleSearchResult(TestGoogleSearchResult.TRANSPORTER),
								   ImdbResultFactory.createImdbResult(TestImdbResult.TRANSPORTER));
			case EQUILIBRIUM_CD1:
				return createMovie(MovieFileFactory.createMovieFile(TesMovieFile.EQUILIBRIUM_CD1), 
								   GoogleSearchResultFactory.createGoogleSearchResult(TestGoogleSearchResult.EQUILIBRIUM),
								   ImdbResultFactory.createImdbResult(TestImdbResult.EQUILIBRIUM));
			case EQUILIBRIUM_CD2:
				return createMovie(MovieFileFactory.createMovieFile(TesMovieFile.EQUILIBRIUM_CD2), 
								   GoogleSearchResultFactory.createGoogleSearchResult(TestGoogleSearchResult.EQUILIBRIUM));
			case SWORDFISH_CD1:
				return createMovie(MovieFileFactory.createMovieFile(TesMovieFile.SWORDFISH_CD1), 
								   GoogleSearchResultFactory.createGoogleSearchResult(TestGoogleSearchResult.SWORDFISH),
								   ImdbResultFactory.createImdbResult(TestImdbResult.SWORDFISH));
			case SWORDFISH_CD2:
				return createMovie(MovieFileFactory.createMovieFile(TesMovieFile.SWORDFISH_CD2), 
								   GoogleSearchResultFactory.createGoogleSearchResult(TestGoogleSearchResult.SWORDFISH));
			case YOUTUBE:
				return createMovie(MovieFileFactory.createMovieFile(TesMovieFile.YOUTUBE), 
								   GoogleSearchResultFactory.createGoogleSearchResult(TestGoogleSearchResult.YOUTUBE),
								   ImdbResultFactory.createImdbResult(TestImdbResult.YOUTUBE));
			case BOX_OFFICE:
				return createMovie(MovieFileFactory.createMovieFile(TesMovieFile.BOX_OFFICE), 
								   GoogleSearchResultFactory.createGoogleSearchResult(TestGoogleSearchResult.BOX_OFFICE),
								   ImdbResultFactory.createImdbResult(TestImdbResult.BOX_OFFICE));
			case THE_MTRX:
				return createMovie(MovieFileFactory.createMovieFile(TesMovieFile.THE_MTRX), 
								   GoogleSearchResultFactory.createGoogleSearchResult(TestGoogleSearchResult.THE_MTRX));
			default:
				return createMovie();
		}
	}
}
